package com.ruoyi.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.FinanceOrder;
import com.ruoyi.domain.HotelOrder;
import com.ruoyi.service.FinanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hotel/finance")
public class FinanceController extends BaseController {

    @Autowired
    FinanceService financeService;

    /**
     * 获取订单数据
     *
     * @param map
     * @return
     */
    @GetMapping("/getOrderList")
    public TableDataInfo getOrderList(@RequestParam Map map) {
        startPage();
        List<Map> list = financeService.getOrderList(map);
        return getDataTable(list);
    }

    /**
     * 获取合计数据
     * @param map
     * @return
     */
    @GetMapping("/getTotalData")
    public AjaxResult getTotalData(@RequestParam Map map){
        return success(financeService.getTotalData(map));
    }

    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestParam Map map)
    {
        List<FinanceOrder> list = financeService.getFinanceListExport(map);
        ExcelUtil<FinanceOrder> util = new ExcelUtil<FinanceOrder>(FinanceOrder.class);
        util.exportExcel(response, list, "结算数据");
    }
}
